home *** CD-ROM | disk | FTP | other *** search
- /* Battle Bit: The Text Adventure
- * You're a lieutenant in earth's toughest military fleet. Your
- * current mission is to guard earth's intergalactic conference hall. */
- using System;
-
- namespace Chapter2 {
- class Class1 {
- static void Main() {
- string input;
- int iAmmo = 12, // player has 12 guesses
- iAlienShip = 49, // the alien ship starts here
- iTarget = 50; // This variable stores your input
-
- /* Game introduction - explains to the player what he needs to
- * do, why he is doing it. The introduction should also, be
- * used to set the games mood and excite the player. */
-
- Console.WriteLine("\n Captain, aliens are attempting "
- + "to land peacefully!\n"
- + "What? How dare they and on the day we're suppose "
- + "to start peace talks.\n"
- + "It just goes to show you, you just can't trust "
- + "those alien scum.\n"
- + "Lieutenant, lock target, I don't want to see one "
- + "alien left alive.\n"
- + "But captain, isn't that the ambassadors ship!\n"
- + "And wasn't he suppose to be coming today?\n"
- + "Lieutenant, are you going to target the alien "
- + "ship or not?\n"
- + "But sir. \n Type in the ships location and fire soldier!\n"
- + "But sir!\n"
- + "Lieutenant, you'll take out that alien scum or I'll "
- + "take you out!\n"
- + "(The captains gun points oddly at your head.) "
- + "Got it? Yes sir!\n");
-
- // location of ship û this just makes it harder to find the ship
- iAlienShip = ((iAlienShip * iAmmo) / (iTarget + 1)) + 3;
-
- while (iAmmo > 0) { // when ammo runs out the loop ends
- Console.WriteLine("\n\n Enter targeting information?");
- input = Console.ReadLine();
- iTarget = int.Parse(input);
-
- if (iTarget == iAlienShip) {
- // if your input equals the ships location
- Console.WriteLine("Alien ship hit, the ships been destroyed sir.");
- break; // break ends loop
- } else if (iTarget > iAlienShip) {
- // when input is too high
- Console.WriteLine("You missed, try aiming a little lower");
- iAmmo--; // ammoùreduces the total ammo by 1
- } else {
- // when input is to low
- Console.WriteLine("You missed, try aiming higher");
- iAmmo--; // also reduces ammo by 1
- }
-
- // The location of the ship moves with each shot
- if (iTarget == 0) {
- iTarget = 1;
- }
- iAlienShip = (iAlienShip * iAmmo) / iTarget;
- }
-
- if (iAmmo > 0) // if you have ammo you must have hit the alien
- Console.WriteLine("\n Good work soldier, remind me to promote you.");
- else // if your out of ammo you can't protect the hall
- Console.WriteLine("\n BOOM!!! You're dead.\n");
-
- Console.WriteLine ("\n Game Over\n");
- }
- }
- }
-
-